package com.example.demo.niuke;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Set;

/**
 * @Description: HUAWEI机试 - 密码验证合格程序
 * @Author: LLL
 * @Date: 2020-03-21 14:24
 **/
public class Main14 {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        //        isQualified();
        String line = null;
        while ((line = br.readLine()) != null) {
            if (line.length() <= 8) {
                System.out.println("NG");
                continue;
            }
            String[] split = line.split("");
            int a = 0;
            int b = 0;
            int c = 0;
            int d = 0;
            for (String s : split) {
                // 大写
                if (65 <= s.charAt(0) && s.charAt(0) <= 90) {
                    a = 1;
                }
                // 小写
                else if (97 <= s.charAt(0) && s.charAt(0) <= 122) {
                    b = 1;
                } else if (48 <= s.charAt(0) && s.charAt(0) <= 57) {
                    c = 1;
                } else {
                    d = 1;
                }

            }
            if (a + b + c + d < 3) {
                System.out.println("NG");
                continue;
            }
            Set<String> set = new HashSet<>();
            int count = 0;
            for (int i = 0; i < line.length() - 3; i++) {
                set.add(line.substring(i, i + 3));
                count++;
            }
            if (count != set.size()) {
                System.out.println("NG");
                continue;
            }
            System.out.println("OK");
        }

    }
}
